package com.hongyuan.venue.ui.home.activity;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.venue.R;
import com.hongyuan.venue.base.AppViewModelFactory;
import com.hongyuan.venue.base.CustomActivity;
import com.hongyuan.venue.data.md5.BaseUtil;
import com.hongyuan.venue.databinding.ActivityVenuePayBinding;
import com.hongyuan.venue.ui.home.view_mode.VenuePayViewModel;

import me.tatarka.bindingcollectionadapter2.BR;

public class VenuePayActivity extends CustomActivity<ActivityVenuePayBinding, VenuePayViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_venue_pay;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public VenuePayViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用NetWorkViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(VenuePayViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();

        setOnRefresh(binding.refresh,REFRESH_0X4);

        binding.comBack.setOnClickListener(view -> finish());

        viewModel.allSelect.set(getBundle().getString("detail"));
        viewModel.allPrice.set(getBundle().getString("allPrice"));
    }

    @Override
    public void initData() {
        super.initData();

    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();

        viewModel.uc.showCouponName.observe(this,s -> {
            if(BaseUtil.isValue(s)){
                binding.couponName.setText(s);
            }else{
                binding.couponName.setText("请选择");
            }

        });
    }
}
